from flytekit.core.context_manager import FlyteContextManager
path = None
# Parameters
path = "/var/folders/jx/54tww2ls58n8qtlp9k31nbd80000gp/T/flyte-ytmvsbhm/raw/a0499d0fbc48ab90edf515f297d056ea"
from IPython.display import display
import pandas as pd
from PIL import Image
df = pd.read_parquet(path)
df["correct"] = ((df.prediction > 0.5) == df.label).astype(int)
df.sort_values(by="correct")[["label", "prediction", "description"]]
| label | prediction | description | |
|---|---|---|---|
| 2 | 0.0 | 0.854929 | This image is named img3.png and contains clouds |
| 0 | 1.0 | 0.963508 | This image is named img1.png and contains hydr... |
| 1 | 1.0 | 0.960557 | This image is named img2.png and contains hydr... |
acc = df["correct"].sum() / len(df)
print(f"accuracy = {acc}")
accuracy = 0.6666666666666666
ctx = FlyteContextManager.current_context()
for i, img in df.iterrows():
if (img.prediction > 0.5) == 1 and img.label == 0.0:
print(f"Image {i}: {img.description}")
local_img = ctx.file_access.get_random_local_path()
ctx.file_access.get(img.remote_source, local_img)
display(Image.open(local_img))
Image 2: This image is named img3.png and contains clouds
for i, img in df.iterrows():
if (img.prediction > 0.5) == img.label:
print(f"Image {i}: {img.description}")
local_img = ctx.file_access.get_random_local_path()
ctx.file_access.get(img.remote_source, local_img)
display(Image.open(local_img))
Image 0: This image is named img1.png and contains hydrocarbon plumes
Image 1: This image is named img2.png and contains hydrocarbon plumes